home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Nebula 2
/
Nebula Two.iso
/
SourceCode
/
Palettes
/
Chart
/
Source
/
PieChartPS.psw
< prev
next >
Wrap
Text File
|
1995-06-12
|
1KB
|
58 lines
// -------------------------------------------------------------------------------------
// custom PS for PieChart palette
// -------------------------------------------------------------------------------------
// draw a slice of pie
defineps _pieDrawSlice(char *thelabel; float labelps;
float xCenter, yCenter, radius;
float startangle, endangle;
float grayOutline, grayLabel)
gsave
% translate to center of circle
xCenter yCenter translate
% outline path to pie slice
newpath
0 0 moveto
0 0 radius startangle endangle arc
closepath
1.415 setmiterlimit
% fill with default color and stroke the slice
gsave fill grestore
grayOutline 0 ge { grayOutline setgray stroke } { newpath } ifelse
% draw tick and label
grayLabel 0 ge {
% draw tick mark in center of arc
grayLabel setgray
gsave
startangle endangle add 2 div rotate
radius 0 translate
newpath
0 0 moveto
labelps .8 mul 0 lineto
stroke
labelps 0 translate
0 0 transform
grestore
itransform
% draw label
/y exch def /x exch def
x y moveto
x 0 lt { (thelabel) stringwidth pop neg 1 sub 0 rmoveto } if
y 0.5 le { 0 labelps y -0.5 ge { 2 div } if neg rmoveto } if
0 labelps 0.10 mul rmoveto
(thelabel) show
} if
grestore
endps